//
//  HomeTableViewCell.m
//  好奇
//
//  Created by ***鹏辉 on 16/9/23.
//  Copyright © 2016年 Zuopenghui. All rights reserved.
//

#import "HomeTableViewCell.h"
#import "UIImageView+WebCache.h"
@interface HomeTableViewCell()

@property (weak, nonatomic) IBOutlet UILabel *nameLable;
@property (weak, nonatomic) IBOutlet UIImageView *iconImage;
@property (weak, nonatomic) IBOutlet UILabel *timeLable;
@property (weak, nonatomic) IBOutlet UILabel *laiYuanLable;
@property (weak, nonatomic) IBOutlet UIButton *pingLunBtn;
@property (weak, nonatomic) IBOutlet UIButton *ZanBtn;

@end
@implementation HomeTableViewCell

-(void)setModel:(HomeTableViewModel *)model
{
    _model = model;
    self.nameLable.text = model.post[@"title"];
    [self.iconImage sd_setImageWithURL:[NSURL URLWithString:model.image]];
    self.timeLable.text = [self Time:model];
    self.laiYuanLable.text = model.post[@"category"][@"title"];
    [self.pingLunBtn setTitle:[NSString stringWithFormat:@"%@",model.post[@"comment_count"]] forState:UIControlStateNormal];
    [self.ZanBtn setTitle:[NSString stringWithFormat:@"%@",model.post[@"praise_count"]] forState:UIControlStateNormal];

}

-(NSString *)Time:(HomeTableViewModel *)model{
    
    NSString*str = [NSString stringWithFormat:@"%@",model.post[@"publish_time"]];
    NSTimeInterval time = [str doubleValue] + 28800;
    NSDate * detaildate = [NSDate dateWithTimeIntervalSince1970:time];
    NSDateFormatter * dateFormatter = [[NSDateFormatter alloc]init];
    [dateFormatter setDateFormat:@"MM/dd HH:mm"];
    NSString * currentDateStr = [dateFormatter stringFromDate:detaildate];
    return currentDateStr;
}

@end
